package com.kwq.designPattern.construct.combine;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @author kangwanqiang
 * @date 2021/2/7
 * @description 组合模式，以雇员类为例
 */
@Data
public class Employee {
    String name;
    String dept;

    Integer salary;
    List<Employee> subordinates;

    public void add(Employee employee) {
        subordinates.add(employee);
    }

    public void remove(Employee employee) {
        subordinates.remove(employee);
    }

    public Employee(String name, String dept, Integer salary) {
        this.name = name;
        this.dept = dept;
        this.salary = salary;
        subordinates = new ArrayList<>();
    }
}
